package com.shihang.crm.utils;

import java.util.List;

public class PageBean {
    //当前页数
    private int currentPage;
    //总记录数
    private int totalCount;
    //每页显示条数
    private int pageSize;
    //总页数
    private int totalPage;
    //分页列表数据
    private List list;

    /**
     *
     * @param currentPage 当前页数
     * @param totalCount //总条数
     * @param pageSize //页大小
     */
    public PageBean(int currentPage, int totalCount, int pageSize) {
        this.totalCount = totalCount;
        if (currentPage <= 0) {
            this.currentPage = 1;
        } else {
            this.currentPage = currentPage;
        }
        this.pageSize = pageSize;
        if(pageSize==0){
            //因为数据量太小，所以页数小一点儿
            this.pageSize=3;
        }
        //计算总页数
        totalPage = (this.totalCount+this.pageSize-1)/this.pageSize;

        //判断当前页数是否超出范围
        if(currentPage>totalPage){
            this.currentPage = totalPage;
        }
    }

    public int getStart(){
        return (currentPage-1)*pageSize;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public List getList() {
        return list;
    }

    public void setList(List list) {
        this.list = list;
    }
}
